package util

import (
	"bytes"
	"strconv"
)

type StringBuilder struct {
	buffer *bytes.Buffer
}

func NewStringBuilder(s string) *StringBuilder {
	return &StringBuilder{
		buffer: bytes.NewBufferString(s),
	}
}

func (b *StringBuilder) AppendInt(i int) *StringBuilder {
	b.buffer.WriteString(strconv.Itoa(i))
	return b
}

func (b *StringBuilder) AppendString(s string) *StringBuilder {
	b.buffer.WriteString(s)
	return b
}

func (b *StringBuilder) AppendHtmlHref(url, name string) *StringBuilder {
	b.buffer.WriteString("<a href='")
	b.buffer.WriteString(url)
	b.buffer.WriteString("'>")
	b.buffer.WriteString(name)
	b.buffer.WriteString("</a>")
	return b
}

func (b *StringBuilder) String() string {
	return b.buffer.String()
}
